using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ABResource
{
    private readonly List<ABAsset> m_Assets;


    public ABAsset[] GetAssets()
    {
        return m_Assets.ToArray();
    }
    public void Rename(string name, string variant)
    {
        Name = name;
        Variant = variant;
    }

    public void AssignAsset(ABAsset asset)
    {
        if (asset.Resource != null)
        {
            asset.Resource.UnassignAsset(asset);
        }

        asset.Resource = this;
        m_Assets.Add(asset);
        m_Assets.Sort(AssetComparer);
    }
    public void UnassignAsset(ABAsset asset)
    {
        asset.Resource = null;
        m_Assets.Remove(asset);
        if (m_Assets.Count <= 0)
        {
        }
    }
    private int AssetComparer(ABAsset a, ABAsset b)
    {
        return a.Guid.CompareTo(b.Guid);
    }
    #region Attr


    public string Name
    {
        get;
        private set;
    }
    public string Variant
    {
        get;
        private set;
    }

    public string FullName
    {
        get
        {
            return Variant != null ? string.Format("{0}.{1}", Name, Variant) : Name;
        }
    }
    #endregion
}
